﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Eg.Core.Data.Repozitory;
using NHibernate;

namespace Eg.Core.Data.Repository.Impl
{
    public class NHibernateRepository<T>:NHibernateBase,IRepository<T> where T : Entity
    {
        public NHibernateRepository(ISessionFactory sessionFactory)
            :base(sessionFactory)
        {

        }

        #region IRepository<T> Members

        public void Add(T item)
        {
            transact(() => session.Save(item));
        }

        public bool Contains(T item)
        {
            if (item.Id == default(Guid))
                return false;
            return transact(() => session.Get<T>(item.Id)) != null;
        }

        public int Count
        {
            get 
            {
                throw new NotImplementedException();
            }
        }

        public bool Remove(T item)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IEnumerable<T> Members

        public IEnumerator<T> GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
